<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
  <style media="screen">
    div{
      width: 100px;
      height: 100px;
      position: absolute;
      background-color: red;
    }
  </style>
</head>
<body>
  <div id="hah"
    v-bind:style="{left:left+'px',top:top+'px'}"
  v-on:mousedown="drag(0,$event)" v-on:mouseup="drag(2)"></div>
  <script src="vue.js"></script>
  <script type="text/javascript">
    var hah=new Vue({
      el: '#hah',
      data: {
        top:100,
        left:100
      },
      methods:{
        drag:function(){
          var startX;
          var startY;
          var startTop;
          var startLeft;

           return function(i,e){
             var that=this;
            switch (i){
              case 0:{
                startTop=this.$data.top;
                startLeft=this.$data.left;
                startX=e.clientX;
                startY=e.clientY;
                document.addEventListener("mousemove",move);
              };break;
              case 2:{
                document.removeEventListener("mousemove",move);
              };break;
            }
            function move(e){
                var endTop=startTop+e.clientY-startY;
                var endLeft=startLeft+e.clientX-startX;
                that.$data.top=endTop;
                that.$data.left=endLeft;
            }
          }
        }()
      }
    });
  </script>
</body>
</html>
